"""
APP 配置
"""
import platform
import urllib
from sqlalchemy.pool import QueuePool

ENV = 'production'
HOST = '0.0.0.0'
PORT = 9091
DEBUG = False
# 新项目使用  python -c 'import os; print(os.urandom(16))' 生成SECRET_KEY
SECRET_KEY = b'e\xa8n\xcf\xc3\xc9\xd9Y\xb1\xdd\xe4B\x95Xh\xeb'
SEND_FILE_MAX_AGE_DEFAULT = 43200

# 默认使用用电内网1的数据库，流水数据使用下面elec_db_2
if platform.system() == 'Linux':
    SQLALCHEMY_DATABASE_URI ='mysql://newuser:password@106.53.97.117:3307/sys'
    SQLALCHEMY_BINDS = {
        'olympic_db': 'mysql://electricity_api_service:GJlfh7&#jg@mmservice-05.mysql.hotgrid.cn:3306/electricity_data',
        'elec_db_2' : 'mysql://electricity_api_service:GJlfh7&#jg@mmservice-05.mysql.hotgrid.cn:3306/electricity_data',
        'ysrd_y':  'mysql://electricity_api_service:GJlfh7&#jg@mmservice-05.mysql.hotgrid.cn:3306/electricity_data'

    }
else:
    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://electricity_data:EF2zUl1GHss3yqay@10.20.7.227:33176/electricity_data'
    SQLALCHEMY_BINDS = {
        'olympic_db': f'mysql://olympic:{urllib.parse.quote("olympic_ysrd@2021")}@rm-2zem57smz83811158bo.mysql.rds.aliyuncs.com:3306/olympic_db',
        'elec_db_2': 'mysql://electricity_data:EF2zUl1GHss3yqay@10.20.7.227:33177/electricity_data',
        'ysrd_y':  'mysql://electricity_api_service:GJlfh7&#jg@mmservice-05.mysql.hotgrid.cn:3306/electricity_data'

    }


SQLALCHEMY_ECHO = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_RECORD_QUERIES = True
SQLALCHEMY_ENGINE_OPTIONS = {
    'echo_pool': True,
    'poolclass': QueuePool,
    'pool_pre_ping': True,
    'pool_size': 20,
    'pool_recycle': 300,
    'pool_timeout': 5
}

_API_NICE_RESP = False

REDIS_HOST = 'electricity-service.redis.hotgrid.cn'
REDIS_PORT = 6379
REDIS_PWD = 'phWOgP05ymg01GaR'
REDIS_DB = 2
